package com.interview.ujiuye5;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.ServerSocket;
import java.net.Socket;

public class MyServer2 {
	public static void main(String[] args) throws Exception {
		System.out.println("服务器启动成功.......");
		ServerSocket serverSocket = new ServerSocket(8080);
		Socket socket = serverSocket.accept();

		InputStream inputStream = socket.getInputStream();
		InputStreamReader reader = new InputStreamReader(inputStream);
		BufferedReader br = new BufferedReader(reader);
		String line = br.readLine();
		System.out.println("服务器接到数据:"+line);
		//返回数据
		OutputStream os = socket.getOutputStream();
		OutputStreamWriter  osw =new OutputStreamWriter(os);
		osw.write(line);
		osw.close();
		serverSocket.close();
	}
}